<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/20 0020
 * Time: 上午 10:58
 */
namespace app\admin\controller;
use app\common\controller\Curt;
class  City extends  Curt {


    public function getall()
    {
        $keyword=input('get.keyword');
        if($keyword){
            $where['c_name|b.p_name']=['like','%'.$keyword.'%'];
        }
        $alias=['ec_city'=>'a','ec_province'=>'b'];//传入数组批量设置数据表以及别名
        $join = [
            ['ec_province','a.p_id=b.id', ],
        ];
        $list = $this->model ->alias($alias) ->join($join) ->order('id desc') ->where($where) ->field("a.*,b.p_name") ->paginate();
        $page = $list->render();
        $this->assign('list', $list);
        $this->assign('page', $page);
    }

    public function showAdd()
    {
       $data=$this->request->param();
        if($data['pid']){
             $this->assign('pid',$data['pid']);
        }
        return $this->fetch();
    }
}